//
//  ConExchangeListDetailController.m
//  Shengzhuli
//
//  Created by FXGuo on 2017/9/6.
//  Copyright © 2017年 kamangkeji. All rights reserved.
//

#import "ConExchangeListDetailController.h"
#import "ActivityNetWork.h"
#import "SZLAccountHelper.h"
#import "UIImage+Extension.h"
#import "MBProgressHUD+MJ.h"
#import "ActiveHaveChangedDetailModel.h"

@interface ConExchangeListDetailController ()
@property (strong, nonatomic) IBOutlet UIImageView *goodsThumbnailImageView;
@property (strong, nonatomic) IBOutlet UILabel *orderNoLabel;
@property (strong, nonatomic) IBOutlet UILabel *goodsNameLabel;
@property (strong, nonatomic) IBOutlet UILabel *activieValueLabel;
@property (strong, nonatomic) IBOutlet UILabel *receiveAddressLabel;
@property (strong, nonatomic) IBOutlet UILabel *receivePersonNameLabel;

@property (strong, nonatomic) IBOutlet UILabel *phoneNumLabel;
@property (strong, nonatomic) IBOutlet UILabel *sendCampanyName;
@property (strong, nonatomic) IBOutlet UILabel *sendNumLabel;
@property (nonatomic, strong) NSMutableArray *dataArray;
@property (nonatomic, strong) ActiveHaveChangedDetailModel *model;
@end

@implementation ConExchangeListDetailController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"商品信息";
    [self loadData];
}
- (void)loadData {
    NSMutableDictionary *param = [NSMutableDictionary dictionary];
    param[@"orderNo"] = self.orderNo;
    param[@"token"] = [SZLAccountHelper shareInstance].token;
    [ActivityNetWork getHaveChangedGoodsDetailWithParame:param response:^(BOOL success, NSString *msg,NSDictionary *dict) {
        if (success) {
            NSLog(@"dict = %@",dict);
            _model = [[ActiveHaveChangedDetailModel alloc] init];
            
            [_model updateModelWithDict:dict];
            NSString *status = [NSString stringWithFormat:@"%@",_model.status];
            if (([status isEqualToString:@"1"])) {
                self.sendNumLabel.hidden = YES;
                self.sendCampanyName.hidden = YES;
            }
            [self refreshSelf];
        }else {
            [MBProgressHUD showError:msg];
        }
    }];
}
- (void)refreshSelf {
    NSLog(@"_model.express = %@",_model.expressCompany);
    NSLog(@"_model.express = %@",_model.courierNumber);

    self.orderNoLabel.text = [@"订单号:" stringByAppendingString:_model.orderNo];
    [self.goodsThumbnailImageView sd_setImageWithURL:[NSURL URLWithString:self.imageString]];
    self.goodsNameLabel.text =_model.productName;
    self.activieValueLabel.text = [NSString stringWithFormat:@"%0.2f * %0.0f",_model.productUnitActiveValue,_model.productCount];
    self.receiveAddressLabel.text = [@"收货地址:" stringByAppendingString:_model.receiveAddress];
    self.receivePersonNameLabel.text =[@"收 货 人:" stringByAppendingString:_model.receivePerson];
    self.phoneNumLabel.text =[@"电   话:" stringByAppendingString:_model.receivePersonPhone];
    NSString *status = [NSString stringWithFormat:@"%@",_model.status];
    if ([status isEqual:@"2"]) {
            self.sendCampanyName.text =[@"快递公司:" stringByAppendingString:_model.expressCompany];
            self.sendNumLabel.text =[@"快递单号:" stringByAppendingString:_model.courierNumber];
    }

}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
